<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04 localStoring</title>
</head>

<body>


    <script>
        //1. 判断是否支持本地存储
        if (window.localStorage) {
            alert('支持');
        } else {
            alert('不支持');
        }

        window.localStorage.name = '小黑';
        window.localStorage['userName'] = '隔壁老王';
        window.localStorage.setItem('kky', 'kisskillyou111');

        var a = window.localStorage.name;
        var b = localStorage['userName'];
        var c = localStorage.getItem('kky');

        console.log('a:', a);
        console.log('b:', b);
        console.log('c:', c);

        localStorage.removeItem('userName');

        localStorage.clear();

        var str = window.localStorage;
        var f = str.key(2);
        console.log('f:', f);
    </script>
</body>

</html>